﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using YFIN.Admin.ViewModels.Admin;
using YFIN.Admin.RiskPreferQuestionServiceRef;

namespace YFIN.Admin.Admin
{
    public partial class RiskPreferManage : UserControl
    {
        RiskPreferManageVM _rpvm;
        public RiskPreferManage()
        {
            InitializeComponent();
            _rpvm=new RiskPreferManageVM();
            this.DataContext = _rpvm;
        }
        private void edit_Click(object sender, RoutedEventArgs e)
        {
            _rpvm.UpdateAnswer(((Button)sender).DataContext);
        }

        private void delete_Click(object sender, RoutedEventArgs e)
        {
            _rpvm.CurrentQuestion = ((Button)sender).DataContext as ModelRiskPreferQuestion;
            _rpvm.DeleteAnswer();
        }

        private void AddContentButton_Click(object sender, RoutedEventArgs e)
        {
            _rpvm.AddAnswer(((Button)sender).DataContext as ModelRiskPreferAnswer);
        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            _rpvm.CurrentQuestion = _rpvm.Questions[((ListBox)sender).SelectedIndex];
        }
    }
}
